<%--
  Created by IntelliJ IDEA.
  User: root
  Date: 2020/3/14
  Time: 22:14
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <title>修改密码--layui后台管理模板 2.0</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <meta name="apple-mobile-web-app-status-bar-style" content="black">
    <meta name="apple-mobile-web-app-capable" content="yes">
    <meta name="format-detection" content="telephone=no">
    <link rel="stylesheet" href="${ctx }/resources/layui/css/layui.css" media="all" />
    <link rel="stylesheet" href="${ctx }/resources/css/public.css" media="all" />
</head>
<body class="childrenBody">
<form class="layui-form layui-row changePwd" method="post" action="${ctx }/changepwd.action">
    <div class="layui-col-xs12 layui-col-sm6 layui-col-md6">
        <div class="layui-input-block layui-red pwdTips">旧密码请输入“123456”，新密码必须两次输入一致才能提交</div>

        <div class="layui-form-item">
            <label class="layui-form-label">用户ID</label>
            <div class="layui-input-block">
                <input type="text" name="userid" value="${user.userid }" class="layui-input layui-disabled">
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">用户名</label>
            <div class="layui-input-block">
                <input type="text" name="realname" value="${user.realname }" disabled class="layui-input layui-disabled">
            </div>
        </div>

<%--        <div class="layui-form-item">--%>
<%--            <label class="layui-form-label">旧密码</label>--%>
<%--            <div class="layui-input-block">--%>
<%--                <input type="pwd" value="" placeholder="请输入旧密码" lay-verify="required|oldPwd" class="layui-input pwd">--%>
<%--            </div>--%>
<%--        </div>--%>

        <div class="layui-form-item">
            <label class="layui-form-label">新密码</label>
            <div class="layui-input-block">
                <input type="pwd" id="pwd" name="pwd" placeholder="请输入新密码" lay-verify="required|newPwd" class="layui-input pwd">
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">确认密码</label>
            <div class="layui-input-block">
                <input type="pwd" name="cpwd"  placeholder="请确认密码" lay-verify="required|confirmPwd" class="layui-input pwd">
            </div>
        </div>
        <div class="layui-form-item">
            <div class="layui-input-block">
                <button class="layui-btn" lay-submit="" lay-filter="changePwd">立即修改</button>
                <button type="reset" class="layui-btn layui-btn-primary">重置</button>
            </div>
        </div>
    </div>
</form>
<script type="text/javascript" src="${ctx }/resources/layui/layui.js"></script>
<%--<script type="text/javascript" src="/resources/js/user.js"></script>--%>
<script>
    layui.use(['form','layer','laydate','table','laytpl'],function(){
        var form = layui.form,
            layer = parent.layer === undefined ? layui.layer : top.layer,
            $ = layui.jquery,
            laydate = layui.laydate,
            laytpl = layui.laytpl,
            table = layui.table;

        //添加表单验证规则
        form.verify({
            oldPwd : function(value, item){
                if(value != "123456"){
                    return "密码错误，请重新输入！";
                }
            },
            newPwd : function(value, item){
                if(value.length < 6){
                    return "密码长度不能小于6位";
                }
            },
            confirmPwd : function(value, item){
                if(!new RegExp($("#oldPwd").val()).test(value)){
                    return "两次输入密码不一致，请重新输入！";
                }
            }
        })
        //修改密码
        form.on("submit(changePwd)",function(response){
            // layer.msg(response.msg);
                layer.msg("密码修改成功！");

            // 显示提交中的 样式
            // var index = layer.msg('提交中，请稍候',{icon: 16,time:false,shade:0.8});
            // setTimeout(function(){
            //     layer.close(index);
            //     layer.msg("密码修改成功！");
            //     // $(".pwd").val('');
            // },1000);
            // return false; //阻止表单跳转。如果需要表单跳转，去掉这段即可。
        })
        //控制表格编辑时文本的位置【跟随渲染时的位置】
        $("body").on("click",".layui-table-body.layui-table-main tbody tr td",function(){
            $(this).find(".layui-table-edit").addClass("layui-"+$(this).attr("align"));
        });

    })
</script>
</body>
</html>
